package com.jiaozi.system.controller;


import com.jiaozi.core.annotation.Log;
import com.jiaozi.core.table.JzTable;
import com.jiaozi.base.utils.bean.R;
import com.jiaozi.system.pojo.param.sys.menu.MenuSaveUpdateParam;
import com.jiaozi.system.pojo.vo.sys.menu.MenuInfoVO;
import com.jiaozi.system.pojo.vo.sys.menu.MenuPageVO;
import com.jiaozi.system.service.SysMenuService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 系统-菜单(SysMenu)表控制层
 *
 * @author jiaozi
 * @since 2024-08-15 14:02:36
 */
@RestController
@RequestMapping("/sysMenu")
@Tag(name = "菜单管理")
public class SysMenuController {
    /**
     * 服务对象
     */
    @Autowired
    private SysMenuService sysMenuService;
    @Operation(summary = "菜单初始化",description = "菜单初始化")
    @GetMapping("/info")
    @ApiOperationSupport(order = 1)
    @Log("菜单初始化")
    public  R<JzTable> info(){
        return R.ok(new JzTable());
    }
    @Operation(summary = "查询菜单树",description = "查询菜单树【本部以及子菜单】")
    @GetMapping("/menuListTree")
    public R<MenuPageVO> menuListTree(){
        return sysMenuService.menuListVOR();
    }


    @Operation(summary = "新增菜单信息",description = "新增菜单信息")
    @PostMapping("/")
    @ApiOperationSupport(order = 1)
    public R menuSave(@RequestBody MenuSaveUpdateParam menuSaveUpdateParam){
        return sysMenuService.menuSave(menuSaveUpdateParam);
    }

    @Operation(summary = "获取菜单信息",description = "获取菜单信息")
    @GetMapping("/{menuId}")
    @ApiOperationSupport(order = 2)
    public R<MenuInfoVO> menuInfo(@Parameter(name ="menuId" ,description = "菜单编号", required = true)
                                              @PathVariable(value = "menuId") String menuId){
        return sysMenuService.menuInfo(menuId);

    }

    @Operation(summary = "修改菜单信息",description = "修改菜单信息")
    @PutMapping("/{menuId}")
    @ApiOperationSupport(order = 3)
    public R menuUpdate(@Parameter(name ="menuId" ,description = "菜单编号", required = true)
                        @PathVariable(value = "menuId") String menuId,@RequestBody MenuSaveUpdateParam menuSaveUpdateParam){
        return sysMenuService.menuUpdate(menuId,menuSaveUpdateParam);
    }


    @Operation(summary = "删除菜单信息",description = "删除菜单信息")
    @DeleteMapping("/{menuId}")
    @ApiOperationSupport(order = 4)
    public R menuDelete(@Parameter(name ="menuId" ,description = "菜单编号", required = true)
                        @PathVariable(value = "menuId") String menuId){
        return sysMenuService.menuDelete(menuId);
    }


    @Operation(summary = "变更菜单状态",description = "变更菜单状态")
    @PutMapping("updateMenuState/{departmentId}")
    @ApiOperationSupport(order = 65)
    public R updateMenuState(@Parameter(name ="departmentId" ,description = "菜单编号", required = true)
                                    @PathVariable(value = "departmentId") String departmentId){
        return sysMenuService.updateMenuState(departmentId);
    }





}

